package org.bits.data;

import java.util.List;
import java.util.Vector;

/*******************************************************************************
 * 
 ******************************************************************************/
public class Filter<T>
{
    /** The name of this filter. */
    private String name;
    /** The test used to filter an item. */
    private FilterCondition condition;
    /** The fields to be displayed in the table. */
    private List<Field<T>> displayFields;
    /** The type of data to be filtered */
    private FilterDataType dataType;

    /***************************************************************************
     * Constructor
     **************************************************************************/
    public Filter( FilterDataType type )
    {
        setName( "Untitled" );
        displayFields = new Vector<Field<T>>();
        dataType = type;
    }

    /***************************************************************************
     * Returns the name of this filter.
     * @return
     **************************************************************************/
    public String getName()
    {
        return name;
    }

    /***************************************************************************
     * Sets the name of this filter.
     * @param name
     **************************************************************************/
    public void setName( String name )
    {
        this.name = name;
    }

    /***************************************************************************
     * Returns the {@link FilterCondition} associated with this filter.
     * @return
     **************************************************************************/
    public FilterCondition getCondition()
    {
        return condition;
    }

    /***************************************************************************
     * Sets the {@link FilterCondition} associated with this filter.
     * @param condition
     **************************************************************************/
    public void setCondition( FilterCondition condition )
    {
        this.condition = condition;
    }

    /***************************************************************************
     * Returns the {@link Field}s that should be display for this filter.
     * @return
     **************************************************************************/
    public List<Field<T>> getDisplayFields()
    {
        return displayFields;
    }

    /***************************************************************************
     * Adds a {@link Field} to display with this filter.
     * @param field
     **************************************************************************/
    public void addDisplayField( Field<T> field )
    {
        displayFields.add( field );
    }

    /***************************************************************************
     * 
     **************************************************************************/
    @Override
    public String toString()
    {
        return name;
    }

    /***************************************************************************
     * @return
     **************************************************************************/
    public FilterDataType getDataType()
    {
        return dataType;
    }
}
